var publishMAppList = {
	load : function () {
		Ext.QuickTips.init();
		this.createGrid(); //建立 Ext table
	},
  
	createGrid : function () {
		var qs =  new QueryString();
		var account = qs.get("account");
		
		var store = new Ext.data.JsonStore ({
	 	 	url:"/ad/sys/com/control/publish/AppInfoService.php?action=getAppInfoRate&account="+account,//getUser().Account,
			root : "row", 
			remoteSort: false,
			totalProperty: 'count',
			fields : ["id","name","startTime","income","incomesum"]
		});
		
		 
		var grid =new Ext.grid.GridPanel({
			renderTo : "grid",
			store :  store,
			height: 330,
			loadMask : true,
			viewConfig : {
				forceFit : true 
			},
				columns : [ 
				new Ext.grid.RowNumberer(),
				{header : "應用程式名稱", dataIndex : "name" , width : 150, sortable : true
					,renderer:function (value , p, record){
						
						return "<a href='/ad/sys/com/control/publish/AppInfoService.php?action=getAppInfoDetail&id=" +
						record.data.id+"'>"+value+"</a>";
						
					}
				},
				{header : "啟用時間", dataIndex : "startTime" , width : 80, sortable : true,
					renderer:function (value , p, record){
						switch(value)
						{
							case 0:
								return '審理中 ';
							default:
								return value;
						}
					}
				},
				{header : "今日的收益", dataIndex : "income" , width : 181, sortable : true},
				{header : "累積收益", dataIndex : "incomesum" , width : 166, sortable : true},
			],
			
			bbar : new Ext.PagingToolbar({
				pageSize :20,
				store : store,
				displayInfo : true,
				displayMsg : "顯示第 {0} 筆到 {1} 筆紀錄,共 {2} 筆紀錄",
				emptyMsg : "沒有紀錄" 
			})
		});	
		
		store.load({
			params:{
				start:0,
				limit:20
			}
		});    
	}
	 
};

Ext.onReady(function (){
	publishMAppList.load();
});